<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateBankDetailsTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('bank_details', function (Blueprint $table) {
            $table->id()->from(config('migration.from'));

            $table->bigInteger('profile_id')->unsigned();
            $table->foreign('profile_id')->references('id')->on('profiles')->onDelete('cascade')->onUpdate('cascade');

            $table->string('name')->nullable();
            $table->string('bik')->nullable();
            $table->string('correspondent_account')->nullable();
            $table->string('inn')->nullable();
            $table->string('checking_account')->nullable();

            $table->enum('master_account', [true])->nullable();

            $table->timestamps();

            $table->unique(['profile_id', 'master_account']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('bank_details');
    }
}
